package cn.bisoft.java.util.common;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

public class ImageUtil
{
	public static void saveImage(String dirPath, BufferedImage image)
	{
		try
		{
			Graphics2D g = (Graphics2D) image.getGraphics();
			
			g.dispose();
			
			image.flush();

			File file = new File(dirPath + "/"+ System.currentTimeMillis() + ".jpg"); // 此目录保存缩小后的关键图
			
			if (!file.exists())
			{
				ImageIO.write(image, "jpg", file); 
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
